<template>
	<view class="washHair">
		<!-- 头部 -->
		<view class="header">
			<!-- 轮播图-->
			<swiper :indicator-dots="true" circular="true" :autoplay="true" :interval="3000" :duration="1000"
			 indicator-active-color="#fff" indicator-color="#ccc">
				<swiper-item :key="index" v-for="(item,index) in 4">
					<image src="../../static/titleImage.png"></image>
				</swiper-item>
			</swiper>
		</view>
		<!-- <!-- 倒计时消毒中 -->
		<view class="container" v-if="type==1">
			<van-circle v-model="currentRate1" :speed="100" layer-color="#ebedf0" color="#FEDC00" stroke-width="14" size="150">
				<view class="">
					消毒中
				</view>
				<van-count-down :time="time1" :format="itemText1" class="countDowm" />
			</van-circle>
		</view>


		<!--洗发中 -->
		<view class="container" v-if="type==2">
			<van-circle v-model="currentRate2" :speed="100" layer-color="#ebedf0" color="#FEDC00" stroke-width="13" size="152">
				<view class="">精选套餐A</view>
				<view class="">洗发中</view>
				<van-count-down :time="time2" :format="itemText2" class="countDowm" />
			</van-circle>
		</view>
		<!-- 洗发完成 -->
		<view class="container" v-if="type==3">
			<van-circle v-model="currentRate" :speed="100" layer-color="#ebedf0" color="#FEDC00" stroke-width="13" size="152">
				<view class="">
					洗发完成
				</view>
				<van-count-down :time="time" :format="itemText" class="countDowm" />
			</van-circle>
		</view>



		<!-- 底部 -->
		<!-- 调用加载 -->
		<view v-if="type==0">

		</view>
		<!-- 当页面为消毒显示 -->
		<view class="clear" v-if="type==1">
			<view>
				消毒注意事项
			</view>
			<text>消毒注意事项消毒注意事项消毒注意事项消毒注意事项消毒注意事项消毒注意事项消毒注意事项消毒注意事项消毒注意事项消毒注意事项消毒注意事项</text>
		</view>
		<!-- 当页面为洗发中显示 -->
		<view class="recommed" v-if="type==2">
			<view class="box">
				<image src="../../static/首页-全部套餐-选中%20副本_slices/编组%206@2x.png" mode=""></image>
			</view>
			<!-- <view class="icon">
			推荐
		</view> -->
			<view class="left">
				<image src="../../static/titleImage.png" mode=""></image>
			</view>
			<view class="right">
				<view class="name">
					<text>精选A套餐</text>
					<view class="min">
						20分钟
					</view>

				</view>
				<view class="content">
					精洗A套餐介绍精洗A套餐介绍精洗A套餐介绍精洗A套餐介绍精洗A套餐介绍精洗A套餐介绍精洗A套餐介绍
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 倒计时进度条
				currentRate1: 0,
				currentRate2: 0,
				real1: 0,
				real2: 0,
				time1: 0,
				time2: 0,
				itemText1: '剩余mm分ss秒',
				itemText2: '剩余mm分ss秒',
				type: 1,
				timer1: null,
				timer2: null
			}
		},
		onLoad() {
			this.jiazai()
			// this.washHairone()
		},
		methods: {
			jiazai(){
				uni.showLoading({
				    title: '加载中'
				});
				
				setTimeout(function () {
				    uni.hideLoading();
				}, 5000);
				
				setTimeout(() =>{
					this.time1= 10 * 1000
					this.time2= 30 * 1000
					this.washHairone()
				}, 5000);
			},
			washHairone() {
				this.timer1 = setInterval(() => {
					this.real1 += 100 / (this.time1 / 1000 - 1)
					this.currentRate1 = Math.ceil(this.real1)
					console.log('this.real1', this.real1)
					console.log('this.currentRate1', this.currentRate1)
					if (this.real1 >= 100 || this.currentRate1 >= 100) {
						clearInterval(this.timer1)
						this.type = 2
						this.washHairtwo()
					}
				}, 1000)
			},
			washHairtwo() {
				console.log(this.type)
				if (this.type == 2) {
					this.timer2 = setInterval(() => {
						this.real2 += 100 / (this.time2 / 1000 - 1)
						this.currentRate2 = Math.ceil(this.real2)
						console.log('this.currentRate1', this.currentRate1)
						if (this.real2 >= 100 || this.currentRate2 >= 100) {
							clearInterval(this.timer2)
							this.type = 3
							console.log(this.type)
						}
					}, 1000)
				}
			}
		},
		computed: {
			text() {
				return this.itemText
			},
		}

	}
</script>

<style lang="less">
	.washHair {
		padding: 30rpx;


		// 头部 
		.header {
			height: 360rpx;
			border-radius: 16px;

			image {
				width: 100%;
			}
		}

		// 主体
		.container {
			margin: 0rpx auto;
			width: 376rpx;
			height: 376rpx;
			border-radius: 50%;
			border: 4rpx dashed #FEDC00;
			display: flex;
			align-items: center;
			justify-content: center;

			canvas {
				position: relative;
			}

			.txt {
				position: absolute;

			}
		}

		// 底部
		// 页面消毒显示
		.clear {
			margin-top: 60rpx;
			font-family: PingFangSC-Medium, PingFang SC;

			view {
				width: 264rpx;
				height: 58rpx;
				font-size: 44rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: rgba(0, 0, 0, 1);
				line-height: 60rpx;
			}

			text {
				width: 690rpx;
				height: 102rpx;
				font-size: 26rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: rgba(74, 74, 74, 1);
				line-height: 36rpx;
			}
		}

		// 推荐页面洗发显示
		.recommed {
			position: relative;
			height: 216rpx;
			background: rgba(255, 255, 255, 1);
			box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.1);
			border-radius: 12rpx;

			.box {
				position: absolute;
				top: 0;
				right: 0;

				image {
					width: 88rpx;
					height: 84rpx;

				}
			}

			// .box {
			// 	position: absolute;
			// 	top: -64rpx;
			// 	right: -64rpx;
			// 	width: 0;
			// 	height: 0;
			// 	border: 64rpx solid;
			// 	border-color: transparent transparent #3C81DE transparent;
			// 	transform: rotate(45deg);

			// 	&::after {
			// 		content: '推荐';
			// 		display: inline-block;
			// 		width: 500rpx;
			// 		height: 200rpx;
			// 		position: relative;
			// 		font-size: 25rpx;
			// 		top: 20rpx;
			// 		left: -19rpx;
			// 		color: #fff;
			// 	}
			// }


			margin-top: 50rpx;
			margin-bottom: 30rpx;
			width: 690rpx;
			height: 216rpx;
			box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
			border-radius: 12rpx;
			display: flex;

		}

		.left {
			width: 180rpx;

			image {
				width: 180rpx;
				height: 216rpx;
				background: rgba(216, 216, 216, 1);
			}
		}

		.right {
			padding: 24rpx 16rpx;
			flex: 1;
			width: 178rpx;
			height: 52rpx;
			font-size: 38rpx;
			font-weight: 400;
			background-color: rgba(255, 255, 255, 1);

			.name {
				display: flex;
				margin-bottom: 10rpx;
			}

			.min {
				margin-left: 12rpx;
				width: 112rpx;
				height: 40rpx;
				line-height: 40rpx;
				text-align: center;
				border-radius: 22rpx;
				font-size: 22rpx;
				color: rgba(255, 174, 0, 1);
				background: rgba(255, 246, 193, 1);
				border: 2rpx solid rgba(255, 246, 193, 1);
			}

			.content {
				font-size: 26rpx;
				color: rgba(74, 74, 74, 1);
				padding-bottom: 30rpx;
			}

		}


	}
</style>
